fix(browser): intercept PageDown/PageUp to snap to page boundary#263
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Apr 21, 2026
Merged
Conversation
Override keyPressEvent in SheetBrowser to handle PageDown/PageUp by jumping to exact page boundaries instead of pixel-based scrolling. 重写SheetBrowser的keyPressEvent,PageDown/PageUp直接跳转到 精确页面边界,避免像素滚动导致的累积偏移。 Log: 修复PageDown翻页时页面边界逐渐偏移的问题 PMS: BUG-353721 Influence: 所有缩放模式下PageDown/PageUp均精确跳转到上/下一页,不再有累积偏移。
deepin pr auto review这段代码实现了一个基本的键盘翻页功能,通过拦截 1. 语法逻辑审查
潜在问题:
2. 代码质量审查
改进建议:
3. 代码性能审查
4. 代码安全审查
潜在风险:
5. 改进后的代码示例void SheetBrowser::keyPressEvent(QKeyEvent *event)
{
if (m_sheet) {
switch (event->key()) {
case Qt::Key_PageDown:
if (!event->isAutoRepeat()) {
m_sheet->jumpToNextPage();
return;
}
break;
case Qt::Key_PageUp:
if (!event->isAutoRepeat()) {
m_sheet->jumpToPrevPage();
return;
}
break;
// 可扩展其他翻页按键
case Qt::Key_Home:
m_sheet->jumpToFirstPage();
return;
case Qt::Key_End:
m_sheet->jumpToLastPage();
return;
default:
break;
}
}
DGraphicsView::keyPressEvent(event);
}6. 头文件注释改进/**
* @brief keyPressEvent
* 处理键盘按键事件,支持 PageDown/PageUp/Home/End 等翻页操作
* @param event 键盘事件对象
*/
void keyPressEvent(QKeyEvent *event) override;总结当前代码实现简单且功能正确,但可以从以下方面改进:
如果产品需求明确只需要 PageDown/PageUp,当前代码已经足够。 |
lzwind
approved these changes
Apr 21, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Override keyPressEvent in SheetBrowser to handle PageDown/PageUp by jumping to exact page boundaries instead of pixel-based scrolling.
重写SheetBrowser的keyPressEvent,PageDown/PageUp直接跳转到
精确页面边界,避免像素滚动导致的累积偏移。
Log: 修复PageDown翻页时页面边界逐渐偏移的问题
PMS: BUG-353721
Influence: 所有缩放模式下PageDown/PageUp均精确跳转到上/下一页,不再有累积偏移。